//
//  LaunchViewController.m
//  Friendsback
//
//  Created by 宋质彬 on 2018/3/9.
//  Copyright © 2018年 宋质彬. All rights reserved.
//

#import "LaunchViewController.h"
#import "DHGuidePageHUD.h"
#import "LaunchBannerView.h"
#import "AppDelegate.h"
@interface LaunchViewController ()<DHGuidePageHUDDelegate,launchBannerViewDelegte>
@property (nonatomic , weak) LaunchBannerView *launchBannerView;
@end

@implementation LaunchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden =YES;
    
    if (self.isFirstLunche) {
        // 静态引导页
        [self setStaticGuidePage];

    }else{
        [self configLaunchBannerView];
    }
    
    
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden =NO;
}

#pragma mark - 设置APP静态图片(Static)引导页
- (void)setStaticGuidePage {
    
    NSMutableArray *imageArray = [[NSMutableArray alloc] init];
    for (NSInteger i = 0; i < 4; i ++) {
        NSString *imageName = nil;
        if (iPhone4) {
            imageName = [NSString stringWithFormat:@"引导页-640x960-%ld.jpg",i + 1];
        }else if (iPhone5) {
            imageName = [NSString stringWithFormat:@"引导页-640x1136-%ld.jpg",i + 1];
        }else if (iphone6) {
            imageName = [NSString stringWithFormat:@"引导页-750x1334-%ld.jpg",i + 1];
        }else if(iphone6Plus){
            imageName = [NSString stringWithFormat:@"引导页-1242x2208-%ld.jpg",i + 1];
        }else if (iPhoneX){
            imageName = [NSString stringWithFormat:@"引导页-1125x2436-%ld.jpg",i + 1];
        }

        [imageArray addObject:imageName];
    }
    
    
    NSArray *imageNameArray = imageArray;
    DHGuidePageHUD *guidePage = [[DHGuidePageHUD alloc] dh_initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) imageNameArray:imageNameArray buttonIsHidden:NO];
    guidePage.guidePageHUDDelegate = self;
    guidePage.slideInto = YES;
    [self.view addSubview:guidePage];
}

#pragma mark - 设置APP动态图(Gif)片引导页
- (void)setDynamicGuidePage {
    NSArray *imageNameArray = @[@"guideImage6.gif",@"guideImage7.gif",@"guideImage8.gif"];
    DHGuidePageHUD *guidePage = [[DHGuidePageHUD alloc] dh_initWithFrame:self.view.frame imageNameArray:imageNameArray buttonIsHidden:YES];
    guidePage.slideInto = YES;
    [self.navigationController.view addSubview:guidePage];
}

#pragma mark - 设置APP视(Viedo)频引导页
- (void)setVideoGuidePage {
    NSURL *videoURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"guideMovie1" ofType:@"mov"]];
    DHGuidePageHUD *guidePage = [[DHGuidePageHUD alloc] dh_initWithFrame:self.view.bounds videoURL:videoURL];
    [self.navigationController.view addSubview:guidePage];
}



#pragma mark - DHGuidePageHUDDelegate
- (void)clickButtonAction{
    [self configLaunchBannerView];
}

#pragma mark - LDLaunchBannerViewDelegte
- (void)comeToAddViewControllerWithUrl:(NSDictionary *)infoDict isTimeOut:(BOOL)isTimeOut{
    
    [(AppDelegate *)[UIApplication sharedApplication].delegate gotoTabbarController];
}

#pragma mark - view
- (void)configLaunchBannerView{
    if (self.launchBannerView == nil) {
        LaunchBannerView *launchBannerView = [[LaunchBannerView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        launchBannerView.bannerViewDelegate = self;
        [self.view addSubview:launchBannerView];
        self.launchBannerView = launchBannerView;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
